<template>
  <el-dialog :title="title" :visible.sync="dialogVisible" :close-on-click-modal="false" width="1100px" append-to-body>
    <div class="">
      <el-form :model="queryParams" ref="queryForm" :inline="true" class="search-form-new" label-width="auto">
        <el-form-item label="运营商" prop="gameCarrierType">
            <el-select v-model="queryParams.gameCarrierType" placeholder="请选择运营商" clearable >
              <el-option v-for="item in carrierTypes" :key="item.id" :label="item.name" :value="item.id" />
             
            </el-select>
          </el-form-item>
        <el-form-item label="时间" prop="timer">
          <el-date-picker v-model="timer" type="daterange" range-separator="至" value-format="yyyy-MM-dd" start-placeholder="开始日期" end-placeholder="结束日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item class="btns">
          <el-button type="primary" icon="el-icon-search" @click="search">搜索</el-button>
          <el-button type="warning" icon="el-icon-refresh" @click="resetQuery">重置</el-button>
        </el-form-item>

      </el-form>
      <div class="table_box">
        <el-table :data="tableData.records" style="width: 100%" stripe>
          <!-- <el-table-column
              prop="num"
              label="卡位编号"
              width="120"
            ></el-table-column> -->

          <el-table-column prop="phone" label="手机号" ></el-table-column>
          <el-table-column prop="accountNumber" label="游戏账号" ></el-table-column>
          <el-table-column prop="goodsId" label="商品编号" ></el-table-column>
          <el-table-column prop="gameName" label="绑定游戏"></el-table-column>
          <el-table-column prop="gameCarrierType" label="绑定游戏类型">
            <template #default="{ row }">
              <div>
                <div v-if="row.gameCarrierType == 1" style="color: red;">腾讯系列</div>
                <div v-if="row.gameCarrierType == 2" style="color: green;">网易系列</div>
                <div v-if="row.gameCarrierType == 3" style="color: #FFB52B;">米哈游系列</div>
                <div v-if="row.gameCarrierType == 4" style="color: blue;">其他系列</div>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="createTime" label="绑定时间"></el-table-column>

        </el-table>
        <pagination v-show="tableData.total > 0" :total="tableData.total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />

      </div>
    </div>
  </el-dialog>
</template>

<script>
import phoneApi from "@/api/phoneManage";
export default {
  name: "",
  data() {
    return {
      dialogVisible: false,
      loading: false,
      title: "换绑记录",
      isEdit: false,
      billTypeList: [],
      billTypeConfig: null, //自定义字段配置
      uploadImgUrl: "",
      imgShowList: [],
      newImages: [],
      imgFileList: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      tableData: {
        records: [],
        total: 0,
      },
      timer: [],

      // 表单参数
      form: {
        type: "手机卡",
        num: "",
        tel: "",
        custodian: "",
        remark: "",
        status: 1,
      },
    };
  },
  created() {
  },
  computed:{
    carrierTypes(){
      return this.$store.getters.gameYunyingshangList
    }
  },
  methods: {
    // 打开弹窗
    open(phone) {
      this.queryParams.phone = phone;
      this.dialogVisible = true;
      this.getList();
    },
    // 重置
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        phone:this.queryParams.phone
      };
      this.timer = []
      this.getList();
    },
    getList() {
      if (this.timer && this.timer.length) {
        this.queryParams.createTimeStart = this.timer[0] + " 00:00:00";
        this.queryParams.createTimeEnd = this.timer[1] + " 23:59:59";
      } else {
        this.queryParams.createTimeStart = "";
        this.queryParams.createTimeEnd = "";
      }
      phoneApi.goodsPhoneRecord(this.queryParams).then((res) => {
        this.tableData.records = res.rows;
        this.tableData.total = res.total;
      });
    },
    search(){
      this.queryParams.pageNum = 1
      this.getList();
    },
    close() {
      this.reset();
      this.dialogVisible = false;
    },
  },
};
</script>
<style scoped lang="css">
</style>
